<?php
/*
 * Created on 19 mars 07
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
 class Product extends Appmodel
 {
 	var $name = 'Product';
 	
 	var $validate = array(
 			'title' => VALID_NOT_EMPTY,
 			'category_id' => VALID_NUMBER,
 			'price_sell' => '/^[-+]?[0-9]*.?[0-9]+/',
 			'price_buy' => '/^[-+]?[0-9]*.?[0-9]+/',
 			'stock' => VALID_NUMBER
 			);
 			
 	var $belongsTo = array('Category' => 
 						array(
 						'className' => 'Category',
 						'conditions' => '',
 						'order' => '',
 						'foreignKey' => 'category_id'
 						)
 					);
 	var $hasAndBelongsToMany = array('Bill' => 
 										array(
 										'className' => 'Bill'
 										)							
 									);
 
 	function viewUnbindProduct($id){
 		$this->unbindModel(array(
							'hasAndBelongsToMany' => array('Bill'),
							'belongsTo' => array('Category')
							)
						);
 		return $this->read(null, $id);
 	}
 }
?>
